<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=8">
    <link rel="stylesheet" type="text/css" href="__HOMESKIN__/jsmind/easyui/public/kube.css">
    <link rel="stylesheet" type="text/css" href="__HOMESKIN__/jsmind/easyui/public/main.css">
    <link rel="stylesheet" type="text/css" href="__HOMESKIN__/jsmind/easyui/themes/easyui.css">
    <link rel="stylesheet" type="text/css" href="__HOMESKIN__/jsmind/style/jsmind.css">
    <link rel="stylesheet" type="text/css" href="__HOMESKIN__/jsmind/easyui/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="__HOMESKIN__/jsmind/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="__HOMESKIN__/jsmind/easyui/themes/icon.css">

    <!--[if lt IE 7]>
    <script type="text/javascript" src="__HOMESKIN__/jsmind/style/entypo/lte-ie7.js"></script>
    <![endif]-->
    <title>创建合同</title>

    <style>
        body{-moz-user-select:none;/*火狐*/
            -webkit-user-select:none;/*webkit浏览器*/
            -ms-user-select:none;/*IE10*/
            -khtml-user-select:none;/*早期浏览器*/
            user-select:none;}
    </style>
</head>

<body>

<div style="background: #cccccc;">
    {if condition="$is_edit_mind eq '1'"}
    <a id="add_root_btn" href="#" class="easyui-linkbutton mini-button mini-button-success">保存思维导图</a>
    {/if}
    {if condition="$id neq 0"}
    <a href="{:url('create_contract/phpword',array('id'=> $id))}" class="easyui-linkbutton mini-button mini-button-success">生成word文件</a>
    {/if}
</div>

<div id="jsmind_container">
</div>
<div id="root_child" class="easyui-menu" style="width:120px; z-index:99999">
    <div data-options="iconCls:'icon-large-shapes'" onClick="root_child_btn">
        <span>请选分类</span>
        <div style="width:150px;" class="menu-text">
            <input type="radio" id="sub1" name="sub" value="sub1" /><span>功能模块</span><br/>
            <input type="radio" id="sub2" name="sub" value="sub2" /><span>硬件设备</span><br/>
            <input type="radio" id="sub3" name="sub" value="sub3" /><span>其他</span><br/>
            <a id="root_child_btn" href="#" class="easyui-linkbutton">提交</a>
        </div>
    </div>
</div>

<div id="mm" class="easyui-menu" style="width:120px; z-index:99999">
    <!--<div data-options="iconCls:'icon-add'">
        <span>增加标签</span>
        <div style="width:150px;">
            <div onClick="add_node()">增加标签</div>
        </div>
    </div>-->
    <style>
        .textbox{margin-bottom: 5px;border-radius: 4px 4px 4px 4px;}
        .textbox .textbox-text{height: 22px;line-height: 22px;width:50%;}
    </style>

    <div data-options="iconCls:'icon-add'" id="add_node" onClick="add_node()" >添加标签</div>
    <div class="menu-sep"></div>
    <div data-options="iconCls:'icon-edit'" onClick="modify_node()">编辑标签</div>
    <div data-options="iconCls:'icon-remove'"  onClick="remove_node()">删除标签</div>
    <div data-options="iconCls:'icon-server-add'" id="hardware_div" onClick="hardware_btn">
        <span>硬件属性</span>
        <div style="width:150px;" class="menu-text">
            <span>单位:</span>&nbsp;<input type="text" class="easyui-textbox" id="hardware_unit" value="台"  style="width:60%;"/><br/>
            <span>单价:</span>&nbsp;<input type="text" class="easyui-textbox" id="hardware_price" value=""  style="width:60%;"/><br/>
            <span>数量:</span>&nbsp;<input type="text"  class="easyui-textbox" id="hardware_num" value="" style="width:60%;" /><br/>
            <a id="hardware_btn" href="#" class="easyui-linkbutton">提交</a>
        </div>
    </div>
    {if condition="$manage eq 1"}
        <div data-options="iconCls:'icon-coins'"onClick="set_price()" id="set_price" >设置价格</div>
        <div data-options="iconCls:'icon-large-shapes'" onClick="edit_combo">
            <span>套餐分类</span>
            <div style="width:150px;" class="menu-text">
                <input type="checkbox" id="combo1" name="combo" value="false">套餐一<br/>
                <input type="checkbox" id="combo2" name="combo" value="false">套餐二<br/>
                <input type="checkbox" id="combo3" name="combo" value="false">套餐三<br/>
                <a id="combo_btn" href="#" class="easyui-linkbutton">完成</a>
            </div>
        </div>
    {/if}

</div>

<div id="win"></div>

<script src="__HOMESKIN__/jsmind/js/jquery-1.4.4.min.js"></script>
<script src="__HOMESKIN__/jsmind/easyui/jquery.easyui.min.js"></script>
<script src="__HOMESKIN__/jsmind/js/jsmind.js" type="text/javascript"></script>
<script src="__HOMESKIN__/jsmind/js/jsmind.screenshot.js" type="text/javascript"></script>
<script src="__HOMESKIN__/jsmind/js/jsmind.draggable.js" type="text/javascript"></script>
<script src="__HOMESKIN__/jsmind/js/jquery.contextmenu.r2.js" type="text/javascript"></script>
<script src="__HOMESKIN__/jsmind/js/html5shiv.js" type="text/javascript"></script>
<script type="text/javascript">
    var is_show_price = {$manage};

    var is_edit_mind = {$is_edit_mind};

    if(is_edit_mind == 1){
        is_edit_mind= true;
    }else {
        is_edit_mind= false;
    }
    var _jm = null;
    var default_price = 1000;
    var data = {$mind_data};
    $.messager.defaults = { ok: "是", cancel: "否" };  //修改显示文字
    function load_jsmind(r){
        if(r != undefined && r != null && r != ''){
            var topic = r;
        }else {
            var topic = '公司合同';
        }
        if(data==null || data ==''){
            if(is_show_price == 0){
                data = [{"id":"root", "isroot":true, "topic":topic,"isreadonly":"true"}];
            }else {
                data = [{"id":"root", "isroot":true, "topic":topic,"isreadonly":"true"}];
            }

        }
        var mind = {
            "meta":{
                "name":"demo",
                "author":"277099040@163.com",
                "version":"0.2",
            },
            "format":"node_array",
            "data":data,
        };
        var options = {
            container:'jsmind_container',
            //editable:true,
            editable:is_edit_mind,
            //theme:'primary',
            theme:'greensea',
            mode :'full'
        }
        _jm = jsMind.show(options,mind);
    }

    function get_selected_nodeid(){
        var selected_node = _jm.get_selected_node();
        if(!!selected_node){
            return selected_node.id;
        }else{
            return null;
        }
    }

    function set_price(){
        $.messager.prompt('对该标签设置价格', '请输入价格', function(r){
            if(r == '' || r == null || r == undefined){
                alert('价格不能为空！');
                return false;
            }
            if(!isNumber(r)){
                alert('价格必须填写数字！');
                return false;
            }
            if (r){
                var data = _jm.get_data('node_array').data; //所有数据
                var selected_id = get_selected_nodeid();//获取节点id
                //只要修改就设置他是人为的设置值
                _jm.get_selected_node().editPrice = 'true';
                update_parent_price(data,selected_id,r);
            }
        });
    }

    function update_parent_price(data,selected_id,price,is_parent = 0){
        price = parseFloat(price);
        if(data != null || data != undefined){
            for(let key  in data){
                if(data[key].id == selected_id){
                    var topic = _jm.get_node(selected_id).topic; //获取当前节点所显示的文本
                    //console.log(_jm.get_node(selected_id).topic);
                    var slip_num = topic.indexOf("/");         //获取 /  在字符串中的位置
                    price =  price.toFixed(2); //该变量是字符串
                    if(slip_num == -1){
                        r = topic + '/'+ price;  //如果没有设置价格就直接赋值
                    }else {
                        topic = topic.substring(0,slip_num)     //截取字符串，再赋值
                        r = topic + '/'+ price;
                    }
                    _jm.get_node(selected_id).price = price; //给节点的价格属性赋值

                    _jm.update_node(selected_id, r);//更改内容
                    var parent_node = _jm.get_node(selected_id).parent; //获取父节点
                    //如果没有父节点就返回
                    if(parent_node == undefined || parent_node == null || parent_node == ''){
                        return false;
                    }
                    parent_node.editPrice = 'false';
                    var children = parent_node.children;
                    var children_price = 0;
                    //如果没有子节点就返回
                    if(children === undefined){
                        return false;
                    }
                    for(let children_key  in children){
                        if(children[children_key].price != undefined){
                            children_price = parseFloat(children_price) + parseFloat(children[children_key].price);
                        }
                    }
                    if(parent_node != null){
                        update_parent_price(data,parent_node.id,children_price,is_parant = 1)
                    }
                }
            }
        }
    }

    function modify_node(){
        $.messager.prompt('编辑标签', '请输入新的标签名', function(r){
            if(r=='' || r==undefined || r == null){
                return false;
            }
            var selected_id = get_selected_nodeid();//获取节点id
            if(is_show_price == 0){
                _jm.update_node(selected_id, r );
            }else{
                var slip_num = r.indexOf("/");         //获取 /  在字符串中的位置
                if(slip_num == -1){
                    //alert('该节点必须有‘/’正斜杠，正斜杠前面是节点名称，正斜杠后面是节点价格');
                    _jm.update_node(selected_id,r);//更改内容
                    update_parent_price(data,selected_id,0.00);
                    return false;
                }
                var price = r.substring(slip_num+1);
                price = parseFloat(price);
                var data = _jm.get_data('node_array').data; //所有数据
                if (r){
                    _jm.get_selected_node().editPrice = 'true';
                    update_parent_price(data,selected_id,price);
                    //_jm.disable_edit();
                }
            }
        });
    }

    function remove_node(){
       /* var selected_id = get_selected_nodeid();
        if(!selected_id){alert('请选择一个节点');return;}
        _jm.remove_node(selected_id);*/
        $.messager.confirm("删除标签", "确定要删除该标签吗？", function (r) {
            if (r) {
                var selected_id = get_selected_nodeid();
                if(!selected_id){alert('请选择一个节点');return;}
                var data = _jm.get_data('node_array').data; //所有数据
                update_parent_price(data,selected_id,0);
                _jm.remove_node(selected_id);
            }
        });
       /* $.messager.confirm('删除标签', '确定要删除该标签吗', function(data){
            if (data) {
                var selected_id = get_selected_nodeid();
                console.log(selected_id);
                //_jm.remove_node();
                _jm.remove_node(selected_id);
                //_jm.remove_node();
            }else {

            }
        });*/
    }

    function add_node(){
        $.messager.prompt('新增标签', '请输入标签名', function(r){
            var nodeid = jsMind.util.uuid.newid();
            var topic = r;
            if (r){
                if(is_show_price == 0){
                    topic = r;
                    //扩展方法， right 将子节点增加到右侧， left 将子节点增加到左侧，默认右侧
                    var node = _jm.add_node(_jm.get_selected_node(), nodeid, topic, null, null, "left");
                }else {
                    topic = r + '/'+default_price;
                    //_jm.enable_edit();
                    //扩展方法， right 将子节点增加到右侧， left 将子节点增加到左侧，默认右侧
                    var node = _jm.add_node(_jm.get_selected_node(), nodeid, topic, null, null,"left");
                    var data = _jm.get_data('node_array').data; //所有数据
                    var selected_id = node.id;//获取节点id
                    node.groupmind_id = _jm.get_node('root').groupmind_id;
                    if(get_selected_nodeid() == 'sub2'){
                        node.hardware_unit = '台';
                        node.hardware_price = default_price;
                        node.hardware_num = 1;
                        //_jm.update_node(get_selected_nodeid());//更改内容
                    }
                    //var selected_id = get_selected_nodeid();//获取节点id
                    update_parent_price(data,selected_id,default_price);
                    // _jm.disable_edit();
                    //ajaxSaveDate(_jm.mind.root);
                }
            }
        });
    }

    function right()
    {
        console.log(e.button);
        var e=window.event;
        if(e.button=="2"){
            console.debug("右键");
        }
    }

    function show_selected(){
        console.log(e.button);
        var selected_node = _jm.get_selected_node();
        if(!!selected_node){
            return selected_node.data.isreadonly;
        }else{
            console.debug("nothing");
        }
    }

    function toggle_node(){
        var selected_id = get_selected_nodeid();
        if(!selected_id){alert('请先选择一个节点');}
        _jm.toggle_node(selected_id);
    }

    function edit_combo(obj){
        var selected_node = _jm.get_selected_node();
        console.log(selected_node);
    }

    function show_detail(){
        var href='CompanyLists.html';
        $('#win').window({
            title:"企业明细",
            width:1200,height:600,
            modal:true,shadow: true,collapsible:false,minimizable:false,maximizable:false,
            content:'<iframe scrolling="no" frameborder="0"  src="'+href+'" style="width:100%;height:99.5%;"></iframe>'
        });
    }

    //判断是否为数字
    function isNumber(val) {
        var regPos = /^\d+(\.\d{1,2})?$/;
        var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
        if (regPos.test(val) || regNeg.test(val)) {
            return true;
        } else {
            return false;
        }
    }

    //给硬件属性设置参数
    $('#hardware_btn').click(function () {
        if(is_show_price == 0){
            alert('您不是管理员不能编辑该节点属性！');
            $('#mm').menu('hide');
            return false;
        }

        var hardware_unit = $("#hardware_unit").textbox('getValue');
        var hardware_price = $("#hardware_price").textbox('getValue');
        var hardware_num = $("#hardware_num").textbox('getValue');

        if(hardware_unit == '' || hardware_unit == null || hardware_unit == undefined){
            hardware_unit = '台';
        }
        if(hardware_num == '' || hardware_num == null || hardware_num == undefined){
            hardware_num = '1';
        }
        console.log(hardware_price);
        if(hardware_price == '' || hardware_price == null || hardware_price == undefined ){
            hardware_price = default_price;
        }

        var totla_price = parseFloat(hardware_num * hardware_price).toFixed();
        //console.log(totla_price);
        _jm.get_selected_node().hardware_unit = hardware_unit;
        _jm.get_selected_node().hardware_price = hardware_price;
        _jm.get_selected_node().hardware_num = hardware_num;
        var selected_id = get_selected_nodeid();//获取节点id
        var data = _jm.get_data('node_array').data; //所有数据
        if (data){
            update_parent_price(data,selected_id,totla_price);
        }
        $('#mm').menu('hide');
    })


    //如果是根节点的子节点就让他选择
    $('#root_child_btn').click(function () {
        $("input[name='sub']:first").checked = true;
        var value = $("input[name='sub']:checked").val();
        var topic = $("input[name='sub']:checked + span").text();
        //var nodeid = jsMind.util.uuid.newid();
        var nodeid = value;
        if(is_show_price == 0){
            //扩展方法， right 将子节点增加到右侧， left 将子节点增加到左侧，默认右侧
            var node = _jm.add_node(_jm.get_selected_node(), nodeid, topic, null,null,"left");
        }else {
            topic = topic + '/'+default_price;
            //_jm.enable_edit();
            //扩展方法， right 将子节点增加到右侧， left 将子节点增加到左侧，默认右侧
            var node = _jm.add_node(_jm.get_selected_node(), nodeid, topic, null,null,"left");
            node.price = default_price;

            _jm.get_selected_node().price = parseFloat(_jm.get_selected_node().price) + default_price;

            var root_topic = _jm.get_selected_node().topic;

            console.log(root_topic);
            var new_root_topic= '项目报价单';
            var slip_num = root_topic.indexOf("/");         //获取 /  在字符串中的位置
            if(slip_num == -1){
                new_root_topic = root_topic + '/'+ _jm.get_selected_node().price;  //如果没有设置价格就直接赋值
            }else {
                root_topic = root_topic.substring(0,slip_num)     //截取字符串，再赋值
                new_root_topic = root_topic + '/'+ _jm.get_selected_node().price;
            }
            _jm.update_node('root', new_root_topic );;
            //var data = _jm.get_data('node_array').data; //所有数据
            //var selected_id = node.id;//获取节点id
            //var selected_id = get_selected_nodeid();//获取节点id
            //update_parent_price(data,selected_id,default_price);
            // _jm.disable_edit();
            //ajaxSaveDate(_jm.mind.root);
        }
        $('#root_child').menu('hide');
    })


    //给该节点提交套餐信息
    $('#combo_btn').click(function () {
        var combo1 = $('#combo1').attr('checked');
        var combo2 = $('#combo2').attr('checked');
        var combo3 =  $('#combo3').attr('checked');

       /* console.log(combo1);
        console.log(combo2);
        console.log(combo3);
        console.log(_jm);
        console.log(_jm.get_selected_node().id);*/
        _jm.get_selected_node().combo1 = combo1;
        _jm.get_selected_node().combo2 = combo2;
        _jm.get_selected_node().combo3 = combo3;
        _jm.get_selected_node().data={'combo1':combo1,'combo2':combo2,'combo3':combo3};
        console.log(_jm.get_selected_node());
        /*console.log(_jm.get_meta());
        console.log(_jm.mind.nodes);*/
        //console.log(_jm.get_data('node_array'));
        $('#mm').menu('hide');
    });

    $("input,select").blur(function () {
        setTimeout(function () {
            let scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
            window.scrollTo(0,Math.max(scrollHeight -1,0));
        },100);
    })

    function getdata(obj){
        var state = 1;
        for (let key in obj) {
            if(state == 1){
                if(obj['children'] != null || obj['children'] != undefined){
                    getdata(obj['children']);
                }
                state = 0;
                return false;
            }
        }
    }

    $(function(){
        console.log(data);
        if(data==null || data =='' || data==undefined){
            $.messager.prompt('编辑根节点', '请填写合同名称', function(r){
                if (r){
                    load_jsmind(r);
                    $("jmnode").live('contextmenu',function(e){
                        if(is_show_price == 1){
                            load_click();
                        }
                        e.preventDefault();
                        var selected_id = _jm.get_selected_node().id;
                        $('#hardware_div').hide();
                        $('#add_node').show();
                        $('#set_price').show();
                        if(_jm.get_selected_node().parent.parent && _jm.get_selected_node().parent.parent.id == 'sub1'){
                            $('#add_node').hide();
                        }

                        if(_jm.get_selected_node().parent !=null && _jm.get_selected_node().parent.parent !=null && _jm.get_selected_node().parent && _jm.get_selected_node().parent.id == 'sub2'){
                            $('#set_price').hide();
                            $('#add_node').hide();
                            $('#hardware_div').show();
                            if(is_show_price == 0){
                                $('#hardware_div').hide();
                            }
                            if(_jm.get_selected_node().hardware_unit != '' && _jm.get_selected_node().hardware_unit != null && _jm.get_selected_node().hardware_unit != undefined && _jm.get_selected_node().hardware_unit != 'false'){
                                $("#hardware_unit").textbox("setValue",_jm.get_selected_node().hardware_unit);
                            }else {
                                $("#hardware_unit").textbox("setValue",'台');
                            }
                            if(_jm.get_selected_node().hardware_price != '' && _jm.get_selected_node().hardware_price != null && _jm.get_selected_node().hardware_price != undefined && _jm.get_selected_node().hardware_price != 'false'){
                                $("#hardware_price").textbox("setValue",_jm.get_selected_node().hardware_price);
                            }else {
                                $("#hardware_price").textbox("setValue",default_price);
                            }
                            if(_jm.get_selected_node().hardware_num != '' && _jm.get_selected_node().hardware_num != null && _jm.get_selected_node().hardware_num != undefined && _jm.get_selected_node().hardware_num != 'false'){
                                $("#hardware_num").textbox("setValue",_jm.get_selected_node().hardware_num);
                            }else {
                                $("#hardware_num").textbox("setValue",1);
                            }
                        }
                        if(selected_id == 'root'){
                            $('#root_child').menu('show', {
                                left: e.pageX,
                                top: e.pageY,
                                hideOnUnhover: false
                            });
                        }else{
                            $('#mm').menu('show', {
                                left: e.pageX,
                                top: e.pageY,
                                hideOnUnhover: false
                            });
                        }
                    });
                }
            });
        }else{
            load_jsmind();
            console.log(_jm);
            $("jmnode").live('contextmenu',function(e){
                if(is_show_price == 1){
                    load_click();
                }
                console.log(_jm.get_data('node_array'))
                console.log("33");
                e.preventDefault();
                var selected_id = _jm.get_selected_node().id;
                $('#hardware_div').hide();
                $('#set_price').show();
                $('#add_node').show();

                if(_jm.get_selected_node().parent !=null && _jm.get_selected_node().parent.parent !=null && _jm.get_selected_node().parent.parent && _jm.get_selected_node().parent.parent.id == 'sub1'){
                    $('#add_node').hide();
                }

                if(_jm.get_selected_node().parent && _jm.get_selected_node().parent.id == 'sub2'){
                    $('#set_price').hide();
                    $('#add_node').hide();
                    $('#hardware_div').show();
                    if(is_show_price == 0){
                        $('#hardware_div').hide();
                    }

                    if(_jm.get_selected_node().hardware_unit != '' && _jm.get_selected_node().hardware_unit != null && _jm.get_selected_node().hardware_unit != undefined && _jm.get_selected_node().hardware_unit != 'false'){
                        $("#hardware_unit").textbox("setValue",_jm.get_selected_node().hardware_unit);
                    }else {
                        $("#hardware_unit").textbox("setValue",'台');
                    }
                    if(_jm.get_selected_node().hardware_price != '' && _jm.get_selected_node().hardware_price != null && _jm.get_selected_node().hardware_price != undefined && _jm.get_selected_node().hardware_price != 'false'){
                        $("#hardware_price").textbox("setValue",_jm.get_selected_node().hardware_price);
                    }else {
                        $("#hardware_price").textbox("setValue",default_price);
                    }
                    if(_jm.get_selected_node().hardware_num != '' && _jm.get_selected_node().hardware_num != null && _jm.get_selected_node().hardware_num != undefined && _jm.get_selected_node().hardware_num != 'false'){
                        $("#hardware_num").textbox("setValue",_jm.get_selected_node().hardware_num);
                    }else {
                        $("#hardware_num").textbox("setValue",1);
                    }

                }

                if(is_edit_mind){
                    if(selected_id == 'root'){
                        $('#root_child').menu('show', {
                            left: e.pageX,
                            top: e.pageY,
                            hideOnUnhover: false
                        });
                    }else{
                        $('#mm').menu('show', {
                            left: e.pageX,
                            top: e.pageY,
                            hideOnUnhover: false
                        });
                    }
                }
            });
        }
    });

    function load_click(){
        console.log(_jm);
        $('#combo1').val(false);
        $('#combo1').attr('checked',false);
        $('#combo2').val(false);
        $('#combo2').attr('checked',false);
        $('#combo3').val(false);
        $('#combo3').attr('checked',false);

        var selected_id = get_selected_nodeid();
        //var data = _jm.get_selected_node().data
        var data = _jm.get_data('node_array').data;
        //console.log(data);
        //console.log(_jm.mind);
        if(data != null || data != undefined){
            for(let key  in data){
                if(data[key].id == selected_id){
                    var combo1 = data[key].combo1 ? data[key].combo1 : false;
                    var combo2 = data[key].combo2 ? data[key].combo2 : false;
                    var combo3 = data[key].combo3 ? data[key].combo3 : false;
                    if(combo1 == 'true' || combo1 === true){
                        console.log('true');
                        $('#combo1').val(combo1);
                        $('#combo1').attr('checked',combo1);
                    }
                    if(combo2 == 'true' || combo2 === true){
                        $('#combo2').val(combo2);
                        $('#combo2').attr('checked',combo2);
                    }
                    if(combo3 == 'true' || combo3 === true){
                        $('#combo3').val(combo3);
                        $('#combo3').attr('checked',combo3);
                    }
                }

                /*if(combo_data[key] != false && combo_data[key] != null && combo_data[key] != undefined){
                    console.log(combo_data[key]);
                    $('#'+ key).val(combo_data[key]);
                    $('#'+ key).attr('checked',true);
                }*/
            }
        }
    }

    $('#add_root_btn').click(function(){
        ajaxSaveDate();
    });

    function ajaxSaveDate() {
        var mind_data = _jm.get_data('node_array');
        console.log(mind_data);
        var mind_string = jsMind.util.json.json2string(mind_data);
        var api = "{:url('create_contract/saveMind',array('save_type'=> $save_type,'is_manage'=>$manage))}";
        $.ajax({
            url:api,
            type:'post',
            data:mind_data,
            dataType:'json',
            success:function (res) {
                if(res.code == 0){
                    $.messager.alert('操作提示', '保存数据成功！')
                    //layer.msg('获取数据成功！' );
                }else {
                    $.messager.alert('操作提示', '<span style="color: red;">保存数据失败！</span>')
                }
            },
            error:function (XMLHttpRequest, textStatus, errorThrown) {
                console.log('出错啦！')
            }
        })

        //getdata(obj);
        /*for (let key in obj) {
            if(key == 'id' && obj['id']== 'root'){
                console.log(obj['id']); // foo, bar
                console.log(obj['index']);
                console.log(obj['topic']);
            }
        }*/
    }


</script>
</body>
</html>
